package com.xms.sdk.core.query;

import java.io.Serializable;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;

/**
 * <p>
 * ColumnSet
 * </p>
 *
 * @author migo
 * @since 2021/9/1
 */
public class ColumnSet implements Serializable {

    public boolean AllColumns = false;

    public List<String> Columns = new LinkedList<>();

    public HashMap<String, String> ColumnFormatting = new HashMap<>();

    public ColumnSet()
    {
    }

    public ColumnSet(boolean allColumns)
    {
        this.AllColumns = allColumns;
    }

    public ColumnSet(String... columns)
    {
        this.Columns = new LinkedList<String>(Arrays.asList(columns));
    }

    public void addColumns(String... columns)
    {
        if (columns != null && columns.length > 0)
        {
            for (String c : columns) {
                this.Columns.add(c);
            }
        }
    }
    public void addColumns(List<String> columns)
    {
        if (columns != null && columns.size() > 0)
        {
            for (String c : columns) {
                this.Columns.add(c);
            }
        }
    }

    public void addColumn(String column)
    {
        this.Columns.add(column);
    }

    public void addColumnFormatting(String key, String value)
    {
        if (!ColumnFormatting.containsKey(key))
        {
            this.ColumnFormatting.put(key, value);
        }
    }
}
